package cn.ck.springcloud.service;

import cn.ck.springcloud.entity.Product;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;

//指定调用的服务 MICROSERVICE-PRODUCT 服务名不区分大小写
//不用标记@Service 在主配置类加上@EnableFeignClients(basePackages = {"cn.ck.springcloud.service"})即可
//加上  fallback 属性 指定熔断处理类
@FeignClient(value = "microservice-product",fallback = ProductClientServiceFallBack.class)
public interface ProductClientService {
    @RequestMapping(value = "/product/get/{id}", method = RequestMethod.GET)
    Product get(@PathVariable("id") Long id);

    @RequestMapping(value = "/product/list", method = RequestMethod.GET)
    List<Product> list();

    @RequestMapping(value = "/product/add", method = RequestMethod.POST)
    boolean add(Product product);
}